
//% color="#AA278D" iconWidth=50 iconHeight=40
namespace MpythonBT {
    //% block="MpythonBT int name [NAME]" blockType="command"
    //% NAME.shadow="string" NAME.defl="MpythonBT"
    export function MpythonBTInt(parameter: any, block: any) {
        let name =parameter.NAME.code;
        console.log(name);
        Generator.addInclude('MPythonintclude', '#include "BluetoothSerial.h"');
        Generator.addObject("MpythonBTIntobject", "BluetoothSerial", "SerialBT");
        Generator.addSetup("MpythonBTIntsetup", `SerialBT.begin(${name});`);
    }
    //% block="MpythonBT Serial.available?" blockType="boolean"
    export function MpythonBTavailable(parameter: any, block: any) {
        Generator.addCode(["SerialBT.available()",Generator.ORDER_UNARY_POSTFIX]);
    }
    //% block="MpythonBT Serial read" blockType="reporter"
    export function MpythonBTread(parameter: any, block: any) {
        Generator.addCode(["SerialBT.read()",Generator.ORDER_UNARY_POSTFIX]);
    }
    //% block="MpythonBTSerial write [STR]" blockType="command"
    //% STR.shadow="number" STR.defl="1"
    export function MpythonBTwrite(parameter: any, block: any) {
            let str = parameter.STR.code;
        Generator.addCode(`SerialBT.write(${str});`);
    } 
}
